<page-header [title]="'应用信息列表'"></page-header>
<nz-card [nzBordered]="false">
  <form nz-form [nzLayout]="'inline'" (ngSubmit)="getNewData()" class="search__form">
    <nz-row [nzGutter]="{ md: 8, lg: 24, xl: 48 }">
      <nz-col nzMd="8" nzSm="24">
        <nz-form-item>
          <nz-form-label nzFor="no">规则编号</nz-form-label>
          <nz-form-control>
            <input nz-input [(ngModel)]="q.no" name="no" placeholder="请输入" id="no">
          </nz-form-control>
        </nz-form-item>
      </nz-col>

      <nz-col [nzSpan]="expandForm ? 24 : 8" [class.text-right]="expandForm">
        <button nz-button type="submit" [nzType]="'primary'" [nzLoading]="loading">查询</button>
        <button nz-button type="reset" (click)="getData()" class="mx-sm">重置</button>
        <a (click)="expandForm=!expandForm">
          {{expandForm ? '收起' : '展开'}}
          <i class="anticon" [class.anticon-down]="!expandForm" [class.anticon-up]="expandForm"></i>
        </a>
      </nz-col>
    </nz-row>
  </form>
  <button nz-button (click)="add(modalContent)" [nzType]="'primary'">
    <i class="anticon anticon-plus"></i>
    <span>新建</span>
  </button>
  <ng-container *ngIf="selectedRows.length > 0">
    <button nz-button class="ml-sm">批量操作</button>
    <nz-dropdown [nzPlacement]="'bottomLeft'">
      <button nz-button nz-dropdown class="ml-sm">
        更多操作
        <i class="anticon anticon-down"></i>
      </button>
      <ul nz-menu>
        <li nz-menu-item (click)="remove()">删除</li>
        <li nz-menu-item (click)="approval()">批量审批</li>
      </ul>
    </nz-dropdown>
  </ng-container>
  <div class="my-md">
    <nz-alert [nzType]="'info'" [nzShowIcon]="true" [nzMessage]="message">
      <ng-template #message>
        已选择
        <strong class="text-primary">{{checkedNumber}}</strong> 项&nbsp;&nbsp; 服务调用总计
        <strong>{{totalCallNo}}</strong> 万
        <a *ngIf="totalCallNo > 0" (click)="st.clearCheck()" class="ml-lg">清空</a>
      </ng-template>
    </nz-alert>
  </div>
  <nz-table #nzTable
        nzBordered
        [nzData]="dataSet"
        [nzFrontPagination]="false"
        [nzLoading]="loading"
        [nzTotal]="total"
        [(nzPageIndex)]="pageIndex"
        [(nzPageSize)]="pageSize"
        (nzCurrentPageDataChange)="currentPageDataChange($event)"
        (nzPageIndexChange)="refreshStatus()"
        (nzPageSizeChange)="refreshStatus()"
        [nzPageSize]="20" [nzScroll]="{ y: '500px' }">
    <thead>
      <tr>
        <th nzShowCheckbox [(nzChecked)]="allChecked" [nzIndeterminate]="indeterminate" (nzCheckedChange)="checkAll($event)"></th>
        <th nzWidth="150px">Name</th>
        <th nzWidth="150px">Age</th>
        <th>Address</th>
        <th>options</th>
      </tr>
    </thead>
    <tbody>
      <tr *ngFor="let data of nzTable.data">
        <td nzShowCheckbox [(nzChecked)]="data.checked" [nzDisabled]="data.disabled" (nzCheckedChange)="refreshStatus()"></td>
        <td>{{data.name}}</td>
        <td>{{data.age}}</td>
        <td>{{data.address}}</td>
        <td>
          <button nz-button nzType="primary" (click)="edit(data.name)">edit</button>
          <button nz-button nzType="default" (click)="view(data.name)">view</button>
          <nz-popconfirm [nzTitle]="'Sure to delete?'" (nzOnConfirm)="deleteRow(data.name)">
            <a nz-popconfirm>Delete</a>
          </nz-popconfirm>
        </td>
      </tr>
    </tbody>
  </nz-table>
</nz-card>
<ng-template #modalContent>
    <form nz-form [formGroup]="validateForm" >
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="appName">应用名称</nz-form-label>
          <nz-form-control [nzSm]="14" [nzXs]="24">
            <input nz-input formControlName="appName" id="appName">
            <nz-form-explain *ngIf="validateForm.get('appName').dirty && validateForm.get('appName').errors">The input is not valid E-mail!</nz-form-explain>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="description">描述</nz-form-label>
          <nz-form-control [nzSm]="14" [nzXs]="24">
            <input nz-input formControlName="description" id="description">
            <nz-form-explain *ngIf="validateForm.get('description').dirty && validateForm.get('description').errors">The input is not valid E-mail!</nz-form-explain>
          </nz-form-control>
        </nz-form-item>
    </form>
</ng-template>

